{{ define "title" }}
  {{ if eq .Data.Singular "tag" }}Tag → {{ .Data.Term }}
  {{ else if eq .Data.Singular "category" }}Category → {{ .Data.Term }}
  {{ else }}Posts{{ end }}
  {{ if isset .Site.Params "seotitle" }} | {{ .Site.Params.seotitle }}{{ else }} | {{ .Site.Title }}{{ end }}
{{ end }}

{{ define "main" }}
  {{ partial "header.html" . }}
  <section class="main post-list">
    <header class="list-header offscreen">
      <h2 class="list-label">Posts List</h2>
    </header>
    {{ $paginator := .Paginate (where .Data.Pages "Type" "post") (index .Site.Params "paginate" | default 10) }}
    {{ if ne $paginator.TotalPages 0 }}
      {{ range $paginator.Pages.ByDate.Reverse }}
        {{ .Render "summary" }}
      {{ end }}
    {{ else }}
      <p>There's nothing here.<br>Create an interesting post with the command:</p>
      <p><code>$ hugo new post/hello-world.md</code></p>
    {{ end }}
    {{ if gt $paginator.TotalPages 1 }}
      <footer class="list-footer">
        <nav class="pagination">
          <h3 class="offscreen">Pagination</h3>
          {{ if $paginator.HasPrev }}
            <a class="pagination-previous" href="{{ $paginator.Prev.URL }}">← Newer Posts</a>
          {{ end }}
          {{ if $paginator.HasNext }}
            <a class="pagination-next" href="{{ $paginator.Next.URL }}">Older Posts →</a>
          {{ end }}
        </nav>
      </footer>
    {{ end }}
  </section>
  {{ partial "footer.html" . }}
{{ end }}
